import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Index from "../views/Index.vue"
import Qzq from "../views/qzqIndex.vue"
import Siguan from "../views/siguanIndex.vue"
import Home from "../views/countyPage.vue"

export const constantRoutes = [
  { path: '/', name: 'Home', component: Home },
  { path: '/zlIndex', name: 'Index', component: Index },
  { path: '/qzq', name: 'Qzq', component: Qzq },
  { path: '/siguan', name: 'Siguan', component: Siguan }
]


// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
let routerReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push(location) {
  return routerReplace.call(this, location).catch(err => err)
}

export default new VueRouter({
  mode: 'hash', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
